!===============================================================
!
! Funzione di HARTMAN (n=3)
!
!===============================================================
!			VARIABLE BOUNDS
!===============================================================
!        0.D0                1.D0          Limits of variable 1
!        0.D0                1.D0             "        "      2
!        0.D0                1.D0             "        "      3

SUBROUTINE HARTMAN3(X,N,F)

      IMPLICIT NONE

      INTEGER          :: N
      DOUBLE PRECISION :: X(N), F

      DOUBLE PRECISION :: A(4,3), C(4), P(4,3), FA
      INTEGER          :: I, J

        A(1,1)=3.D0
        A(2,1)=0.1D0
        A(3,1)=3.D0
        A(4,1)=0.1D0

        A(1,2)=10.D0
        A(2,2)=10.D0
        A(3,2)=10.D0
        A(4,2)=10.D0

        A(1,3)=30.D0
        A(2,3)=35.D0
        A(3,3)=30.D0
        A(4,3)=35.D0

        C(1)=1.D0
        C(2)=1.2D0
        C(3)=3.D0
        C(4)=3.2D0

        P(1,1)=0.3689D0
        P(2,1)=0.4699D0
        P(3,1)=0.1091D0
        P(4,1)=0.03815D0

        P(1,2)=0.1170D0
        P(2,2)=0.4387D0
        P(3,2)=0.8732D0
        P(4,2)=0.5743D0

        P(1,3)=0.2673D0
        P(2,3)=0.7470D0
        P(3,3)=0.5547D0
        P(4,3)=0.8828D0

        F  = 0.D0
        FA = 0.D0

        DO I=1,4
           DO J=1,3
              FA = FA + A(I,J)*((X(J)-P(I,J))**2)
           END DO
           F  = F - C(I)*DEXP(-FA)
           FA = 0.D0
        END DO

      RETURN

END
